<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});
Route::resource('projects', 'ProjectsController', ['only' => ['index', 'show', 'create', 'store', 'update', 'edit', 'destroy']]);
//注册页面和行为
Route::get("/register","RegisterController@index");
Route::post("/register","RegisterController@register");
//登录页面和行为
Route::get("/login","LoginController@index")->name("login.index");
Route::post("/login","LoginController@login")->name("login.login");
//退出行为
Route::get("/logout","LoginController@logout")->name("logout");
//个人设置页面和行为
Route::get("/user/me/setting","UserController@setting")->name("user.setting");
Route::post("/user/me/setting","UserController@settingStore")->name("user.settingStore");

//文章列表页(都可以)
//默认情况下，RouteServiceProvider 会在命名空间组中引入你的路由文件，
//让你不用指定完整的 App\Http\Controllers 命名空间前缀就能注册控制器路由。
//因此，你只需要指定命名空间 App\Http\Controllers 之后的部分

//Route::get('/posts', '\App\Http\Controllers\PostController@index');
//文章列表页
Route::get('/posts', 'PostController@index');
//文章详情页
//Route::get('/show/{post}','PostController@show')->where('post','^[0-9]*$');
Route::get('/show/{post}','PostController@show')->where('post','^\d+$');
//创建文章
Route::get('/posts/create','PostController@create');
Route::post('/posts','PostController@store');

//图片上传
Route::post('/posts/img/upload','PostController@imageUpload');
//文章详情页
Route::get('/posts/{post}','PostController@show')->name('posts.show');
//编辑文章
Route::get('/posts/{post}/edit','PostController@edit');
Route::put('/posts/{post}','PostController@update');
//删除文章
Route::get('/posts/{post}/delete','PostController@delete');
Route::delete('/posts/{post}/delete','PostController@delete');

//增加文章评论
Route::post('/posts/{post}/comment','PostController@comment');

Route::get('/posts/{post}/zan','PostController@zan');
Route::get('/posts/{post}/unzan','PostController@unzan');

//个人中心
Route::get('user/{user}','\App\Http\Controllers\UserController@show');
Route::post('user/{user}/fan','\App\Http\Controllers\UserController@fan');
Route::post('user/{user}/unfan','\App\Http\Controllers\UserController@unfan');

